<?php

//命令行执行

require './comm.php';

array_shift($argv);

if (!isset($argv[0], $routes[$argv[0]])) {
    echo PHP_EOL.'[参数错误]'.PHP_EOL;
    return;
}

$route = $routes[$argv[0]];
array_shift($argv);

echo PHP_EOL;

try {
    $result = call_user_func_array([new $route[0], $route[1]], $argv);
    if (is_array($result) || is_object($result)) {
        echo json_string($result, 1);
    } else {
        print_r($result);
    }
}
catch (\Throwable $e) {
    echo json_string(filter_err($e, 1), 1);
}

echo PHP_EOL;
